package cn.oscar.service.imp;

import cn.oscar.mapper.VoucherMapper;
import cn.oscar.service.VoucherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import commonUtils.entities.Restful;
import commonUtils.entities.Voucher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VoucherServiceImp extends ServiceImpl<VoucherMapper, Voucher> implements VoucherService {


    @Override
    public Restful<List<Voucher>> selectAllVoucher() {
        List<Voucher> list = list();
        return Restful.success(list);
    }

    @Override
    public Restful<String> addVoucher(Voucher voucher) {
        save(voucher);
        return Restful.success("添加优惠券成功");
    }

    @Override
    public Restful<String> updateVoucher(Voucher voucher) {
        updateById(voucher);
        return Restful.success("优惠券修改成功");
    }

    @Override
    public Restful<String> deleteVoucherById(Long id) {
        removeById(id);
        return Restful.success("优惠券删除成功");
    }
}
